package com.itrash.android.test;


import com.itrash.android.R;
import com.itrash.android.activity.user.UserLoginActivity;

import android.content.Intent;
import android.widget.Button;
import android.widget.EditText;

public class ItrashAuthenticatedActivityTestCase extends ItrashActivityTestCase<UserLoginActivity> {
	private String 					 userEmail;
	private String 					 userName;
	private String 					 userPass;
	
	protected EditText				 userEmailView;
	protected EditText				 userPassView;
	
	protected Button                 authButton;
	
	public ItrashAuthenticatedActivityTestCase(String userEmail, String userPass) {
		super(com.itrash.android.activity.user.UserLoginActivity.class);
		this.userEmail = userEmail;
		this.userName = userEmail.substring(0, userEmail.indexOf("@") - 1);
		this.userPass = userPass;
	}
	
	@Override
	protected void setUp() throws Exception {
	    super.setUp();
	    
        Intent userLoginIntent = new Intent(getInstrumentation().getTargetContext(), com.itrash.android.activity.user.UserLoginActivity.class);
		userLoginIntent.putExtra(com.itrash.android.activity.user.UserLoginActivity.USER_EMAIL_PARAM, userEmail);         
        setActivityIntent(userLoginIntent);
	    	    
	    userEmailView = (EditText) getActivity().findViewById(R.id.user_email);
        userPassView = (EditText) getActivity().findViewById(R.id.user_pass);        
	    authButton = (Button) getActivity().findViewById(getActivity().getAuthButtonId());
	    
		solo.enterText(userEmailView, "");
		solo.enterText(userEmailView, userEmail);
		
		solo.enterText(userPassView, "");
		solo.enterText(userPassView, userPass);
		
		solo.clickOnButton(solo.getString(R.string.login_user_button));
		
		solo.waitForActivity(com.itrash.android.activity.household.HouseholdMenuActivity.class, 30000);		
		verifyHouseholdMenuActivityUI(userName);			    
	}				
}